

<form class="layui-form" lay-filter="layuiadmin-form-smscp" id="layuiadmin-form-smscp" style="padding: 20px 30px 0 0;">
  <div class="layui-form-item">
    <label class="layui-form-label">供应商</label>
    <div class="layui-input-block">
      <script type="text/html" template lay-done="layui.data.sendParams(d.params)">
        <select name="provider_id" lay-verify="required" id="provider_id">
          <option value=""></option>
        </select>
      </script>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">审核状态</label>
    <div class="layui-input-block">
      <script type="text/html" template>
        <input type="radio" name="status" value="1" title="正常" {{ d.params.status == '正常' ? 'checked' : '' }}>
        <input type="radio" name="status" value="0" title="禁用" {{ d.params.status == '正常'? '' : 'checked' }}>
      </script>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label"></label>
    <div class="layui-input-inline">
      <input type="button" lay-submit lay-filter="LAY-app-smscp-submit" value="立即提交" class="layui-btn">
    </div>
  </div>
</form>

<script>
  layui.data.sendParams = function(params){
    layui.use(['index', 'form'], function(){
      var $ = layui.$
          ,form = layui.form;
      //供应商下拉框
      $.ajax({
        url:layui.setter.HOST+'providers' //模拟接口
        ,type:"GET"
        ,dataType:"json"
        ,async:true
        ,success:function (res) {
          if(res.code == 0){
            for(var i=0;i<res.data.length;i++){
              if(res.data[i].status == '正常'){
                $('#provider_id').append("<option value='"+res.data[i].id+"'>"+res.data[i].name+"</option>");
              }
              form.render('select');
              form.val("layuiadmin-form-smscp", {
                "provider_id": params.provider_id
              })
            }
          }
        }
      });
    })
  };
</script>